<template>
  <div class="goods-hot">
    <h3>{{ { 1: '24小时热销', 2: '周热销', 3: '总热销' }[type] }}</h3>
    <goodsItem v-for="i in list" :key="i.id" :goods="i"></goodsItem>
  </div>
</template>
<script>
import { goodsHotGet } from '@/api/product'
import { useRoute } from 'vue-router'
import { ref } from 'vue'
import goodsItem from '@/views/category/components/goods-item.vue'
export default {
  name: 'GoodsHot',
  components: {
    goodsItem
  },
  props: {
    type: {
      type: [Number, String],
      default: '1'
    }
  },
  setup (props) {
    const route = useRoute()
    const list = ref([])
    goodsHotGet({
      type: props.type,
      limit: 3,
      id: route.params.id
    }).then(res => {
      list.value = res.result
      //   console.log('热销', res.result)
    })
    return { list }
  }
}
</script>
<style scoped lang="less">
.goods-hot {
  h3 {
    height: 70px;
    background: @helpColor;
    color: #fff;
    font-size: 18px;
    line-height: 70px;
    padding-left: 25px;
    margin-bottom: 10px;
    font-weight: normal;
  }
  ::v-deep .goods-item {
    background: #fff;
    width: 100%;
    margin-bottom: 10px;
    img {
      width: 200px;
      height: 200px;
    }
    p {
      margin: 0 10px;
    }
    &:hover {
      transform: none;
      box-shadow: none;
    }
  }
}
</style>
